/**
 * 
 */
package com.taobao.wolfwolf.hibernate.service.impl;

import java.util.List;

import com.taobao.wolfwolf.hibernate.dao.SproductDao;
import com.taobao.wolfwolf.hibernate.pojo.Sproduct;
import com.taobao.wolfwolf.hibernate.service.SproductService;

/**
 * @author qinanhg@gmail.com
 *
 * 创建时间: 2012-1-2 下午1:54:12
 */
public class SproductServiceImpl extends BaseServiceImpl implements SproductService {

	private SproductDao sdao;
	/* (non-Javadoc)
	 * @see com.taobao.wolfwolf.hibernate.service.SproductService#findById(int)
	 */
	@Override
	public Sproduct findById(int id) {
		try {
			return sdao.findById(id);
		} catch (Exception e) {
			System.out.println("获取单个商品出错！！");
		}
		return null;
	}
	
	@Override
	public Sproduct findById(boolean lazy, int id) {
		try {
			return sdao.findById(lazy, id);
		} catch (Exception e) {
			e.printStackTrace();
			System.out.println("延迟加载获取单个商品id出错");
		}
		return null;
	}

	/* (non-Javadoc)
	 * @see com.taobao.wolfwolf.hibernate.service.SproductService#findByName(java.lang.String)
	 */
	@Override
	public List<Sproduct> findByName(String name) {
		// TODO Auto-generated method stub
		return null;
	}

	/* (non-Javadoc)
	 * @see com.taobao.wolfwolf.hibernate.service.SproductService#findAll()
	 */
	@Override
	public List<Sproduct> findAll() {
		try {
			return sdao.findAll();
		} catch (Exception e) {
			System.out.println("获取全部商品出错");
		}
		return null;
	}

	/* (non-Javadoc)
	 * @see com.taobao.wolfwolf.hibernate.service.SproductService#paging(int, int)
	 */
	@Override
	public List<Sproduct> paging(int page, int limit) {
		try {
			return sdao.paging(page, limit);
		} catch (Exception e) {
			System.out.println("单个商品分页出错");
		}
		return null;
	}

	/* (non-Javadoc)
	 * @see com.taobao.wolfwolf.hibernate.service.SproductService#getTotal()
	 */
	@Override
	public long getTotal() {
		try {
			return sdao.getTotal();
		} catch (Exception e) {
			System.out.println("获取单个商品记录总数出错");
		}
		return -1;
	}

	public SproductDao getSdao() {
		return sdao;
	}

	public void setSdao(SproductDao sdao) {
		this.sdao = sdao;
	}
}
